package client;
import java.util.List;
import java.util.Scanner;

import org.ejs.bean.FileManagerRemote;
import org.ejs.network.ServerAddress;




public class Client {
	public static void main(String args[]) throws Exception {
		int i =1;
		if(i==2)
		{
			System.out.println("client 2");
			ServerAddress s = new ServerAddress("127.0.0.1", 14122);
			ClientBeanThread client = new ClientBeanThread(s,"C:\\Users\\Slimm\\Desktop\\client2\\");
			client.start();
			FileManagerRemote file = client.getFile();
			file.add("02_Bright_Lights_Bigger_City.mp3");
			file.add("10-alicia_keys-put_it_in_a_love_song_(featuring_beyonce)-SongsLover.com.mp3");
			List<String> list = null;
			Scanner sc = new Scanner(System.in);
			String str ="";
			while(true){
				System.out.println("tape la commande");
				str = sc.nextLine();
				if(str.equals("get")){
					System.out.println("All Files");
					list=client.getAllFile();
					for (String string : list) {
						System.out.println(string);
					}
				}
				if(str.contains(":")){
	            	String[] split = str.split(":");
	            	if(split[0].equals("move")){
						client.findAndMove(split[1]);
					}
	            	if(split[0].equals("dl")){
						client.findAndDl(split[1]);
					}
				}
				if(str.equals("my file")){
					list = file.getFiles();
					for (String string : list) {
						System.out.println("my file");
						System.out.println(string);
					}
				}
				if(str.equals("kill")){
					file.disconnect();
				}
			}
		}
		if(i==3)
		{
			System.out.println("client 3");
			ServerAddress s = new ServerAddress("127.0.0.1", 14145);
			ClientBeanThread client = new ClientBeanThread(s,"C:\\Users\\Slimm\\Desktop\\client3\\");
			client.start();
			FileManagerRemote file = client.getFile();
			List<String> list = null;
			file.add("test.jpg");
			Scanner sc = new Scanner(System.in);
			String str ="";
			while(true){
				System.out.println("tape la commande");
				str = sc.nextLine();
				if(str.equals("get")){
					System.out.println("All Files");
					list=client.getAllFile();
					for (String string : list) {
						System.out.println(string);
					}
				}
				if(str.contains(":")){
	            	String[] split = str.split(":");
	            	if(split[0].equals("move")){
						client.findAndMove(split[1]);
					}
	            	if(split[0].equals("dl")){
						client.findAndDl(split[1]);
					}
				}
				if(str.equals("my file")){
					list = file.getFiles();
					for (String string : list) {
						System.out.println("my file");
						System.out.println(string);
					}
				}
				if(str.equals("kill")){
					file.disconnect();
				}
			}
		}
		if(i==1)
		{
			System.out.println("client 1");
			ServerAddress s = new ServerAddress("127.0.0.1", 14121);
			ClientBeanThread client = new ClientBeanThread(s,"C:\\Users\\Slimm\\Desktop\\client1\\");
			client.start();
			FileManagerRemote file = client.getFile();
			file.add("01_The_Lady_Killer_Theme_Intro.mp3");
			file.add("04_Wildflower.mp3");
			file.add("05_Bodies.mp3");
			List<String> list = null;
			Scanner sc = new Scanner(System.in);
			String str ="";
			while(true){
				System.out.println("tape la commande");
				str = sc.nextLine();
				if(str.equals("get")){
					System.out.println("All Files");
					list=client.getAllFile();
					for (String string : list) {
						System.out.println(string);
					}
				}
				if(str.contains(":")){
	            	String[] split = str.split(":");
	            	if(split[0].equals("move")){
						client.findAndMove(split[1]);
					}
	            	if(split[0].equals("dl")){
						client.findAndDl(split[1]);
					}
				}
				if(str.equals("my file")){
					list = file.getFiles();
					System.out.println("my file");
					for (String string : list) {
						System.out.println(string);
					}
				}
				if(str.equals("kill")){
					file.disconnect();
				}
			}
		}
	}
}
